using System.Collections;

namespace Geekees.App.HRAssistant.Core.Configuration
{
	public class DaoSettingCollection : CollectionBase
	{
		public DaoSettingCollection() { }
		public DaoSettingCollection( DaoSettingCollection value )
		{
			this.AddRange( value );
		}
		public DaoSettingCollection( DaoSetting[] value )
		{
			this.AddRange( value );
		}
		public DaoSetting SingleDaoSetting()
		{
			for( int i = 0; i < List.Count; i++ )
			{
				DaoSetting ds = ( DaoSetting )List[i];
				if( ds.IsActive )
					return ds;

			}
			return null;
		}
		public DaoSettingCollection DaoSettings()
		{
			DaoSettingCollection dsc = new DaoSettingCollection();
			for( int i = 0; i < List.Count; i++ )
			{
				DaoSetting ds = ( DaoSetting )List[i];
				if( ds.IsActive )
					dsc.Add( ds );
			}
			return dsc;
		}
		public DaoSetting this[int index]
		{
			get { return ( ( DaoSetting )( List[index] ) ); }
			set { List[index] = value; }
		}
		public int Add( DaoSetting value )
		{
			return List.Add( value );
		}
		public void AddRange( DaoSetting[] value )
		{
			for( int Counter = 0; ( Counter < value.Length ); Counter = ( Counter + 1 ) )
			{
				this.Add( value[Counter] );
			}
		}
		public void AddRange( DaoSettingCollection value )
		{
			for( int Counter = 0; ( Counter < value.Count ); Counter = ( Counter + 1 ) )
			{
				this.Add( value[Counter] );
			}
		}
		public bool Contains( DaoSetting value )
		{
			return List.Contains( value );
		}
		public void CopyTo( DaoSetting[] array, int index )
		{
			List.CopyTo( array, index );
		}
		public int IndexOf( DaoSetting value )
		{
			return List.IndexOf( value );
		}
		public void Insert( int index, DaoSetting value )
		{
			List.Insert( index, value );
		}
		new public DaoSettingEnumerator GetEnumerator()
		{
			return new DaoSettingEnumerator( this );
		}
		public void Remove( string dsName )
		{
			for( int i = 0; i < List.Count; i++ )
			{
				DaoSetting ds = ( DaoSetting )List[i];
				if( ds.AssemblyName == dsName )
				{
					List.Remove( ds );
				}
			}
		}
		public void Remove( DaoSetting value )
		{
			List.Remove( value );
		}

		public class DaoSettingEnumerator : object, IEnumerator
		{
			private IEnumerator Base;
			private IEnumerable Local;
			public DaoSettingEnumerator( DaoSettingCollection Mappings )
			{
				this.Local = Mappings;
				this.Base = Local.GetEnumerator();
			}

			public DaoSetting Current
			{
				get { return ( ( DaoSetting )( Base.Current ) ); }
			}

			object IEnumerator.Current
			{
				get { return Base.Current; }
			}

			public bool MoveNext()
			{
				return Base.MoveNext();
			}
			bool IEnumerator.MoveNext()
			{
				return Base.MoveNext();
			}
			public void Reset()
			{
				Base.Reset();
			}
			void IEnumerator.Reset()
			{
				Base.Reset();
			}
		}
	}	
}
